package com.jt.controller;

import org.springframework.stereotype.Component;

import java.util.List;


public class MyWorker extends  Thread{

    private String name;//保存线程的名字
    private List<Runnable> tasks;
    //利用构造方法,给成员变量赋值

    public MyWorker(String name, List<Runnable> tasks) {
        super(name);
        this.tasks = tasks;
    }
    @Override
    public void run() {
        while (tasks.size()>0){
            Runnable remove = tasks.remove(0);
            remove.run();
        }

    }
}
